﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BusinessLogicLayer.DataObject
{
    public class Safekeeping
    {
        public string ID { get; set; }
        public string SafekeepingID { get; set; }
        public string EditorUserID { get; set; }
        public string EditorUserName { get; set; }
        public string Title { get; set; }
        public string TakeDescription { get; set; }
        public string GiveDescription { get; set; }
        public string Status { get; set; }
        public string Timestamp { get; set; }
        public string BackColor { get; set; }

        public Safekeeping(DataAccessLayer.Safekeeping Safekeeping)
        {
            this.ID = Safekeeping.ID.ToString();
            this.SafekeepingID = Safekeeping.SafekeepingID.ToString();
            this.EditorUserID = Safekeeping.EditorUserID.ToString();
            this.EditorUserName = Safekeeping.sUser.Users.Last().Username;
            this.Title = Safekeeping.Title;
            this.TakeDescription = Safekeeping.TakeDescription;
            this.GiveDescription = Safekeeping.GiveDescription;
            switch ((SafekeepingStatus)Safekeeping.SafekeepingStatusID)
            {
                case SafekeepingStatus.Inprogress:
                    this.Status = "تحویل گرفته شده";
                    break;
                case SafekeepingStatus.Completed:
                    this.Status = "تحویل داده شده";
                    break;
            }
            this.Timestamp = Safekeeping.Timestamp.ToHijriSolarString();
            this.BackColor = Safekeeping.IsDeleted ? "#FF5555" : "#FFFFFF";
        }

        public static List<Safekeeping> Convert(List<DataAccessLayer.Safekeeping> Safekeepings)
        {
            return (Safekeepings.ConvertAll(new Converter<DataAccessLayer.Safekeeping, Safekeeping>(p => (new Safekeeping(p)))));
        }
    }
}
